<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BFC</title>
    <style>
        .container {
            width: 300px;
            border: 1px solid #000;

            /*触发BFC*/
            overflow: hidden;
            height: 400px;
        }

        .box1{
            height: 20px;
            margin: 50px 0;
            background-color: blue;
            border: 1px solid purple;
        }

        .box2{
            height: 20px;
            margin: 60px 0;
            background-color: yellow;
            border: 1px solid pink;
        }

    </style>
</head>
<body>
<div class="container">
    <div class="box1"></div>
    <div class="box2"></div>
</div>
</body>
</html>